package com.ruoyi.system.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.LabProjectWorkResearchPersonnel;
import com.ruoyi.system.service.ILabProjectWorkResearchPersonnelService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 实验室工作研究课题人员Controller
 * 
 * @author jun.wang
 * @date 2022-04-12
 */
@RestController
@RequestMapping("/system/personnel")
public class LabProjectWorkResearchPersonnelController extends BaseController
{
    @Autowired
    private ILabProjectWorkResearchPersonnelService labProjectWorkResearchPersonnelService;

    /**
     * 查询实验室工作研究课题人员列表
     */
    // @PreAuthorize("@ss.hasPermi('system:personnel:list')")
    @GetMapping("/list")
    public TableDataInfo list(LabProjectWorkResearchPersonnel labProjectWorkResearchPersonnel)
    {
        startPage();
        List<LabProjectWorkResearchPersonnel> list = labProjectWorkResearchPersonnelService.selectLabProjectWorkResearchPersonnelList(labProjectWorkResearchPersonnel);
        return getDataTable(list);
    }

    /**
     * 导出实验室工作研究课题人员列表
     */
    // @PreAuthorize("@ss.hasPermi('system:personnel:export')")
    @Log(title = "实验室工作研究课题人员", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(LabProjectWorkResearchPersonnel labProjectWorkResearchPersonnel)
    {
        List<LabProjectWorkResearchPersonnel> list = labProjectWorkResearchPersonnelService.selectLabProjectWorkResearchPersonnelList(labProjectWorkResearchPersonnel);
        ExcelUtil<LabProjectWorkResearchPersonnel> util = new ExcelUtil<LabProjectWorkResearchPersonnel>(LabProjectWorkResearchPersonnel.class);
        return util.exportExcel(list, "personnel");
    }

    /**
     * 获取实验室工作研究课题人员详细信息
     */
    // @PreAuthorize("@ss.hasPermi('system:personnel:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(labProjectWorkResearchPersonnelService.selectLabProjectWorkResearchPersonnelById(id));
    }

    /**
     * 新增实验室工作研究课题人员
     */
    // @PreAuthorize("@ss.hasPermi('system:personnel:add')")
    @Log(title = "实验室工作研究课题人员", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody LabProjectWorkResearchPersonnel labProjectWorkResearchPersonnel)
    {
        return toAjax(labProjectWorkResearchPersonnelService.insertLabProjectWorkResearchPersonnel(labProjectWorkResearchPersonnel));
    }

    /**
     * 修改实验室工作研究课题人员
     */
    // @PreAuthorize("@ss.hasPermi('system:personnel:edit')")
    @Log(title = "实验室工作研究课题人员", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody LabProjectWorkResearchPersonnel labProjectWorkResearchPersonnel)
    {
        return toAjax(labProjectWorkResearchPersonnelService.updateLabProjectWorkResearchPersonnel(labProjectWorkResearchPersonnel));
    }

    /**
     * 删除实验室工作研究课题人员
     */
    // @PreAuthorize("@ss.hasPermi('system:personnel:remove')")
    @Log(title = "实验室工作研究课题人员", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(labProjectWorkResearchPersonnelService.deleteLabProjectWorkResearchPersonnelByIds(ids));
    }
}
